package com.desire.test;

import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;

/**
 * @author desire
 */
public class _02_输出功能 {
    public static void main(String[] args) throws FileNotFoundException {
        System.out.println("1234");
        System.out.print("123456"); // 必须要有参数

        //对话框输出
        JOptionPane.showMessageDialog(null, "hello");
        JOptionPane.showMessageDialog(null, "信息错误", "error", JOptionPane.ERROR_MESSAGE);

        //io 文件写入
        PrintWriter printWriter = new PrintWriter("C:\\Users\\desire\\Desktop\\javaProject\\01-javaBase\\src\\main\\resources\\user.txt");  //每次写入会直接覆盖
        printWriter.write("这是测试");
        printWriter.close();

        //表示追加
        PrintWriter printWriter1 = new PrintWriter(new FileOutputStream("C:\\Users\\desire\\Desktop\\javaProject\\01-javaBase\\src\\main\\resources\\user2.txt", true));
        printWriter1.printf("今日日期：%1$tF %1$tT %1$tA %n", System.currentTimeMillis());
        printWriter1.close();
    }
}
